package com.chenxin.wms.controller;

import com.chenxin.common.annotation.Log;
import com.chenxin.common.core.controller.BaseController;
import com.chenxin.common.core.page.TableDataInfo;
import com.chenxin.common.enums.BusinessType;
import com.chenxin.common.utils.poi.ExcelUtil;
import com.chenxin.wms.domain.LocationEntity;
import com.chenxin.wms.domain.vo.LocationVO;
import com.chenxin.wms.service.ILocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 货位资料Controller
 *
 * @author gry
 * @date 2025-04-14
 */
@RestController
@RequestMapping("/wms/location")
public class LocationController extends BaseController {
    @Autowired
    private ILocationService locationService;

    /**
     * 查询货位资料列表
     */
    @PreAuthorize("@ss.hasPermi('wms:location:list')")
    @GetMapping("/list")
    public TableDataInfo list(LocationEntity locationEntity) {
        startPage();
        List<LocationVO> list = locationService.selectLocationList(locationEntity);
        return getDataTable(list);
    }

    /**
     * 导出货位资料列表
     */
    @PreAuthorize("@ss.hasPermi('wms:location:export')")
    @Log(title = "货位资料", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LocationEntity locationEntity) {
        List<LocationVO> list = locationService.selectLocationList(locationEntity);
        ExcelUtil<LocationVO> util = new ExcelUtil<>(LocationVO.class);
        util.exportExcel(response, list, "货位资料数据");
    }

}
